package com.csxy.six;

import io.swagger.v3.oas.models.Components;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Contact;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.info.License;
import io.swagger.v3.oas.models.security.SecurityRequirement;
import io.swagger.v3.oas.models.security.SecurityScheme;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class SwaggerConfig {

    @Bean
    public OpenAPI fleaMarketAuthOpenAPI() {
        return new OpenAPI()
                .info(new Info()
                        .title("跳蚤市场-认证服务API")
                        .version("v1.0")
                        .description("跳蚤市场用户认证与授权接口文档")
                        .contact(new Contact()
                                .name("跳蚤市场技术团队")
                                .email("tech@flea-market.com")
                                .url("https://flea-market.com"))
                        .license(new License()
                                .name("MIT")
                                .url("https://opensource.org/licenses/MIT")))
                .addSecurityItem(new SecurityRequirement().addList("JWT"))
                .components(new Components()
                        .addSecuritySchemes("JWT", new SecurityScheme()
                                .name("JWT")
                                .type(SecurityScheme.Type.HTTP)
                                .scheme("bearer")
                                .bearerFormat("JWT")
                                .description("登录后获取的Token，格式: Bearer {token}")));
    }
}